<?php
namespace app\api\controller\member;
use app\common\controller\BaseController;
use app\common\service\member\MemberBillService;
use hg\apidoc\annotation as Apidoc;
/**
 * @Apidoc\Title("账单信息")
 * @Apidoc\Group("member")
 * @Apidoc\Sort("250")
 */
class MemberBill extends BaseController
{
    /**
     * @Apidoc\Title("查询账单明细参数")
     * @Apidoc\Query(ref="app\common\model\member\MemberBillModel", field="id")
     * @Apidoc\Returned(ref="app\common\model\member\MemberBillModel")
     */
    public function getParams()
    {
        $data = MemberBillService::getParams(member_id(true));
        return success($data);
    }

    /**
    * @Apidoc\Title("账单明细")
    * @Apidoc\Query(ref="pagingQuery")
    * @Apidoc\Query(ref="sortQuery")
    * @Apidoc\Query(ref="searchQuery")
    * @Apidoc\Query(ref="dateQuery")
    * @Apidoc\Returned(ref="expsReturn")
    * @Apidoc\Returned(ref="pagingReturn")
    * @Apidoc\Returned("list", type="array", desc="账单明细列表", children={
    *   @Apidoc\Returned(ref="app\common\model\member\MemberBillModel", field="id,member_id,money,principal,commission,principal_balance,commission_balance,type,member_account_id,data_id,title,remark,is_delete,create_uid,update_uid,delete_uid,create_time,update_time,delete_time")
    * })
    */
    public function list()
    {
        $where = $this->buildWhere([
            'type',
        ]);
        $where = $this->where(where_delete($where));
        $member_id = member_id(true);
        $where[] = ['member_id','=',$member_id];
        //月份筛选
        $param = $this->params(['month' => null]);
        if(!$param['month'] && $param['month']!="undefined"){
            $param['month'] =date('Y-m');
        }
        $data = MemberBillService::list($where, $this->page(), $this->limit(), $this->order(),'id,money,title,remark,create_time,principal_balance,commission_balance',$param['month']);
        return success($data);
    }

}
